/*** 
 * @_______________#########_______________________ 
 * @______________############_____________________ 
 * @______________#############____________________ 
 * @_____________##__###########___________________ 
 * @____________###__######_#####__________________ 
 * @____________###_#######___####_________________ 
 * @___________###__##########_####________________ 
 * @__________####__###########_####_______________ 
 * @________#####___###########__#####_____________ 
 * @_______######___###_########___#####___________ 
 * @_______#####___###___########___######_________ 
 * @______######___###__###########___######_______ 
 * @_____######___####_##############__######______ 
 * @____#######__#####################_#######_____ 
 * @____#######__##############################____ 
 * @___#######__######_#################_#######___ 
 * @___#######__######_######_#########___######___ 
 * @___#######____##__######___######_____######___ 
 * @___#######________######____#####_____#####____ 
 * @____######________#####_____#####_____####_____ 
 * @_____#####________####______#####_____###______ 
 * @______#####______;###________###______#________ 
 * @________##_______####________####______________ 
 * @
 * @Author: ipk518 18163976442@163.com
 * @Date: 2024-06-19 10:31:14
 * @LastEditors: ipk518 121206530@qq.com
 * @LastEditTime: 2025-01-23 09:00:23
 * @FilePath: /etws-sxk2307/src/dataShare/dataShare.h
 * @Description: 
 * @************佛祖保佑************
 * @Copyright (c) 2024 by etws@quyujiang, All Rights Reserved. 
 */
#ifndef _DATASHARE_H_
#define _DATASHARE_H_

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <list>
#include <queue>
#include <mutex>
#include <condition_variable>

using namespace std;

#define TRANSMIT_MAX    256

class shareSub
{
public:
    shareSub(){};
    virtual ~shareSub() {};
    virtual void update(int m_flag,vector<uint8_t>& dataIn) = 0;////需要将vector提取出来
    virtual void test(char* m,int len) = 0;
public:
    int m_ackChannel; //0默认响应雷象上位机，1响应小上位机。（标志自清零）
};


class sharePub
{
private:
    std::mutex m_finishMtx;
    std::condition_variable m_finishCond;
    list<shareSub *> m_sub;

protected:
    bool m_notifyFinish = true; //默认已经完成
    
public:
    friend class Uio;
    sharePub() {};
    virtual ~sharePub() {};
public:
    int m_status;
    void attach(shareSub *ob);
    void remove(shareSub *ob);
    void notify(int m_flag,vector<uint8_t>& dataIn);
    bool wait(const size_t timeout = -1);
    virtual void request(int m) = 0;
    virtual void pulish(int m,vector<uint8_t>& dataIn) = 0;
};

#endif